interface Function {
    myApply: (params: any, args: any[]) => void
}

Function.prototype.myApply = function(context, args) {
    context.fn = this
    const result = context.fn(args)
    delete context.fn
    return result
}

function foo2(this: any, arr: any[]) {
    console.log(this.name, arr)
}

foo2.myApply({name: 'kaho'}, [1, 2, 3])